<template>
  <div>
    <FormPanel ref="formPanel" :list="formList" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />

    <div style="height:47px;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <el-button @click="closeDrawer">取 消</el-button>
      <el-button @click="commitHandle(60521004)" type="primary">确 定</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { auditReportDto } from '@/api/omSale/ActualSales/SalesApproval';
export default {
  mixins: [dictionary],
  props: ['rowData'],

  data() {
    this.saveData = null;
    return {
      formList: this.createdFrom()
    };
  },
  components: {},
  methods: {
    createdFrom() {
      return [
        {
          type: 'TEXT_AREA',
          label: '审批意见',
          fieldName: 'checkDesc',
          placeholder: '请输入',
          selfCols: 3,
          rules: [{ required: true, message: '请输入', trigger: 'blur' }]
        }
      ];
    },

    changeHandle(val) {
      this.saveData = val;
    },
    async commitHandle(type) {
      this.$refs.formPanel.SUBMIT_FORM();
      if (this.saveData != null) {
        let saveData = [];
        this.rowData.map(x => {
          let json = {
            id: x.reportId,
            salesCustomerId: x.salesCustomerId,
            checkDesc: this.saveData.checkDesc,
            reportStatus: 60521004
          };
          saveData.push(json);
        });

        const res = await auditReportDto(saveData);
        if (res.resultCode == 200) {
          if (1 == res.data.code) {
            this.$notify.success({ title: '提示信息', message: '操作成功' });
            this.closeDrawer();
          } else {
            this.$notify.error({ title: '提示信息', message: '操作失败' });
          }
        }
      }
    },
    closeDrawer() {
      this.$emit('close', false, 'refresh');
    }
  }
};
</script>
